package org.bigdata.framework.core.controller;


import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.bigdata.framework.core.log.annotation.SysLog;
import org.bigdata.framework.core.log.enums.BusinessType;
import org.bigdata.framework.core.log.enums.OperatorType;
import org.bigdata.framework.core.model.Advertisement;
import org.bigdata.framework.core.model.Answer;
import org.bigdata.framework.core.model.Audit;
import org.bigdata.framework.core.model.Browse;
import org.bigdata.framework.core.model.Category;
import org.bigdata.framework.core.model.ClassesOnline;
import org.bigdata.framework.core.model.ClassesOnlineComment;
import org.bigdata.framework.core.model.Collect;
import org.bigdata.framework.core.model.Comment;
import org.bigdata.framework.core.model.Config;
import org.bigdata.framework.core.model.Course;
import org.bigdata.framework.core.model.CourseComment;
import org.bigdata.framework.core.model.CourseQuestion;
import org.bigdata.framework.core.model.Live;
import org.bigdata.framework.core.model.LiveQuestion;
import org.bigdata.framework.core.model.Member;
import org.bigdata.framework.core.model.Message;
import org.bigdata.framework.core.model.Online;
import org.bigdata.framework.core.model.OnlineQuestion;
import org.bigdata.framework.core.model.Order;
import org.bigdata.framework.core.model.Paper;
import org.bigdata.framework.core.model.Question;
import org.bigdata.framework.core.model.QuestionDatabase;
import org.bigdata.framework.core.model.ShortFilm;
import org.bigdata.framework.core.model.ShortFilmComment;
import org.bigdata.framework.core.model.User;
import org.bigdata.framework.core.model.UserRole;
import org.bigdata.framework.core.protocol.IBaseService;
import org.bigdata.framework.core.protocol.IPublicService;
import org.bigdata.framework.core.utils.DateUtils;
import org.bigdata.framework.core.utils.DyLogAnnotations;
import org.bigdata.framework.core.utils.MD5;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


import springfox.documentation.annotations.ApiIgnore;

@ApiIgnore
@Controller
public class AddUpdateController extends BaseController{

	@Autowired
	private IBaseService baseService;
	@Autowired
	private IPublicService publicService;
	
	private static String FILESERVER = "";
	private static String FILEPATH = "";

	static {
		Properties properties_config = new Properties();
		InputStream in_config = AddUpdateController.class.getClassLoader().getResourceAsStream("config.properties");
		try {
			properties_config.load(in_config);

			FILESERVER = properties_config.getProperty("file.server");
			FILEPATH = properties_config.getProperty("file.path");
		} catch (IOException e) {
		}
	}
	@SysLog(title="新增-广告",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("advertisementAddUpdate")
	@ResponseBody
	public void advertisementAddUpdate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String name1 = Thread.currentThread().getStackTrace()[1].getMethodName();
		Method method = this.getClass().getMethod(name1, HttpServletRequest.class,HttpServletResponse.class);
		
		String id = request.getParameter("id");
		String name = request.getParameter("name");
		String courseId = request.getParameter("courseId");
		String startTime = request.getParameter("startTime");
		String endTime = request.getParameter("endTime");
		String showTime = request.getParameter("showTime");
		String type = request.getParameter("type");
		String sort = request.getParameter("sort");
		String filePath = request.getParameter("filePath");
		HashMap<String, String>r=new HashMap<String, String>();
		User user = publicService.findUser((Integer) request.getSession().getAttribute("userid"));
		try {
			if(id==null ||"".equals(id)){//新增
				HashMap<String, Object> queryParams = new HashMap<String, Object>();
				queryParams.put("=,name", name);
				queryParams.put("=,createUser", user.getUsername());
				Integer categoryCount = publicService.getAdvertisementCount(queryParams);
				if(categoryCount!=null && categoryCount>0){
					r.put("result", "fail");
					r.put("msg", "广告名称已存在");
				}else{
					DyLogAnnotations.alterAnnotationOn(method, BusinessType.INSERT,"新增-广告");
					
					Advertisement advertisement = new Advertisement();
					advertisement.setCourseId(Integer.parseInt(courseId));
					advertisement.setStartTime(startTime);
					advertisement.setEndTime(endTime);
					advertisement.setSubmitTime(DateUtils.getDateTime());
					advertisement.setStatus(0);//0-待审核， 1=不通过，2=通过
					advertisement.setCreateTime(DateUtils.getDateTime());
					advertisement.setCreateUser(user.getUsername());
					advertisement.setShowTime(showTime);
					advertisement.setName(name);
					advertisement.setType(type);
					advertisement.setSort(sort);
					advertisement.setAuditType("0");
					advertisement.setFilePath(filePath==null?null:filePath.replace(FILESERVER, "").replace(FILEPATH, "").replace("//", "/"));
					Advertisement saveAdvertisement = baseService.saveAdvertisement(advertisement);
					auditAdd("0", null, null, "", saveAdvertisement.getId(), "0", user.getId(), user.getUsername(), "5");
					
					r.put("result", "success");
					r.put("msg", "保存成功");
				}
				
			}else{//更新
				
				HashMap<String, Object> queryParams = new HashMap<String, Object>();
				queryParams.put("=,name", name);
				queryParams.put("=,createUser", user.getUsername());
				Integer categoryCount = publicService.getAdvertisementCount(queryParams);
				
				List<Advertisement> config2 = publicService.getAdvertisement(queryParams, 1, categoryCount);
				queryParams=null;
				boolean flag=true;
				if(config2!=null&& config2.size()>0){
					for (Advertisement config : config2) {
						if(!config.getId().equals(Integer.parseInt(id))){
							flag=false;
							break;
						}
					}
				}
				
				if(!flag){
					r.put("result", "fail");
					r.put("msg", "广告名称已存在");
				}else{
					DyLogAnnotations.alterAnnotationOn(method, BusinessType.UPDATE,"编辑-广告");
					
					Advertisement advertisement = publicService.findAdvertisement(Integer.parseInt(id));
					advertisement.setCourseId(Integer.parseInt(courseId));
					advertisement.setStartTime(startTime);
					advertisement.setEndTime(endTime);
					advertisement.setSubmitTime(DateUtils.getDateTime());
					advertisement.setStatus(0);//-1-已注销 0-待审核 1-审核通过 2-已上架 3-已下架
					advertisement.setName(name);
					advertisement.setShowTime(showTime);
					advertisement.setType(type);
					advertisement.setSort(sort);
					advertisement.setAuditType("0");
					advertisement.setFilePath(filePath==null?null:filePath.replace(FILESERVER, "").replace(FILEPATH, "").replace("//", "/"));
					baseService.editAdvertisement(advertisement);
					auditAdd("0", null, null, "", advertisement.getId(), "0", user.getId(), user.getUsername(), "5");
					r.put("result", "success");
					r.put("msg", "保存成功");
				}
			}
			
		} catch (Exception e) {
			e.printStackTrace();
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@RequestMapping("browseAddUpdate")
	@ResponseBody
	public void browseAddUpdate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		String name1 = Thread.currentThread().getStackTrace()[1].getMethodName();
		Method method = this.getClass().getMethod(name1, HttpServletRequest.class,HttpServletResponse.class);
		
		String id = request.getParameter("id");
		String type = request.getParameter("type");
		String memberId = request.getParameter("memberId");
		String resourceId = request.getParameter("resourceId");
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			if(id==null ||"".equals(id)){//新增
				
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.INSERT,"新增-浏览记录");
				
				Browse browse = new Browse();
				browse.setCreateTime(DateUtils.getDateTime());
				browse.setMemberId(Integer.parseInt(memberId));
				browse.setResourceId(Integer.parseInt(resourceId));
				browse.setType(type);
				baseService.saveBrowse(browse);
			}else{//更新
				
				
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.UPDATE,"编辑-浏览记录");
				
				Browse browse = publicService.findBrowse(Integer.parseInt(id));
				browse.setMemberId(Integer.parseInt(memberId));
				browse.setResourceId(Integer.parseInt(resourceId));
				browse.setType(type);
				baseService.editBrowse(browse);
			}
			r.put("result", "success");
			r.put("msg", "保存成功");
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="新增-栏目",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("categoryAddUpdate")
	@ResponseBody
	public void categoryAddUpdate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		String name1 = Thread.currentThread().getStackTrace()[1].getMethodName();
		Method method = this.getClass().getMethod(name1, HttpServletRequest.class,HttpServletResponse.class);
		
		String id = request.getParameter("id");
		String name = request.getParameter("name");
		String sort = request.getParameter("sort");
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			if(id==null ||"".equals(id)){//新增
				

				HashMap<String, Object> queryParams = new HashMap<String, Object>();
				queryParams.put("=,name", name);
				Integer categoryCount = publicService.getCategoryCount(queryParams);
				if(categoryCount!=null && categoryCount>0){
					r.put("result", "fail");
					r.put("msg", "栏目名称已存在");
				}else{

					DyLogAnnotations.alterAnnotationOn(method, BusinessType.INSERT,"新增-栏目");
					
					Category category = new Category();
					category.setName(name);
					category.setSort(Integer.parseInt(sort));
					baseService.saveCategory(category);
					
					r.put("result", "success");
					r.put("msg", "保存成功");
					
				}
				queryParams=null;
				
			}else{//更新

				HashMap<String, Object> queryParams = new HashMap<String, Object>();
				queryParams.put("=,name", name);
				Integer categoryCount = publicService.getCategoryCount(queryParams);
				
				List<Category> config2 = publicService.getCategory(queryParams, 1, categoryCount);
				queryParams=null;
				boolean flag=true;
				if(config2!=null&& config2.size()>0){
					for (Category config : config2) {
						if(!config.getId().equals(Integer.parseInt(id))){
							flag=false;
							break;
						}
					}
				}
				
				if(!flag){
					r.put("result", "fail");
					r.put("msg", "栏目名称已存在");
				}else{
					DyLogAnnotations.alterAnnotationOn(method, BusinessType.UPDATE,"编辑-栏目");
					
					Category category = publicService.findCategory(Integer.parseInt(id));
					category.setName(name);
					category.setSort(Integer.parseInt(sort));
					baseService.editCategory(category);
					
					r.put("result", "success");
					r.put("msg", "保存成功");
					
				}
				queryParams=null;
			}
			
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="新增-网班",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("classesOnlineAddUpdate")
	@ResponseBody
	public void classesOnlineAddUpdate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		String name1 = Thread.currentThread().getStackTrace()[1].getMethodName();
		Method method = this.getClass().getMethod(name1, HttpServletRequest.class,HttpServletResponse.class);
		
		String id = request.getParameter("id");
		String name = request.getParameter("name");
		String description = request.getParameter("description");
		String tag = request.getParameter("tag");
		String cover = request.getParameter("cover");
		String userIds = request.getParameter("userIds");
		HashMap<String, String>r=new HashMap<String, String>();
		User user = publicService.findUser((Integer) request.getSession().getAttribute("userid"));
		if(description!=null){
			description=description.replace(" src=\""+FILESERVER, " src=\"").replace(" src=\""+FILEPATH, " src=\"").replace(" src=\"//", " src=\"/");
		}
		try {
			if(id==null ||"".equals(id)){//新增
				
				HashMap<String, Object> queryParams = new HashMap<String, Object>();
				queryParams.put("=,name", name);
				queryParams.put("=,createUser", user.getUsername());
				Integer classesOnlineCount = publicService.getClassesOnlineCount(queryParams);
				if(classesOnlineCount!=null && classesOnlineCount>0){
					r.put("result", "fail");
					r.put("msg", "网班已存在");
				}else{
					DyLogAnnotations.alterAnnotationOn(method, BusinessType.INSERT,"新增-网班");
					
					ClassesOnline classesOnline = new ClassesOnline();
					classesOnline.setCover(cover==null?null:cover.replace(FILESERVER, "").replace(FILEPATH, "").replace("//", "/"));
					classesOnline.setCreateTime(DateUtils.getDateTime());
					classesOnline.setCreateUser(user.getUsername());
					classesOnline.setDescription(description);
					classesOnline.setName(name);
					classesOnline.setStatus("0");
					classesOnline.setTag(tag);
					classesOnline.setAuditType("0");
					classesOnline.setUserIds(userIds);
					ClassesOnline saveClassesOnline = baseService.saveClassesOnline(classesOnline);
					auditAdd("0", null, null, "", saveClassesOnline.getId(), "0", user.getId(), user.getUsername(), "2");
					r.put("result", "success");
					r.put("msg", "保存成功");
				}
				
				
			}else{//更新
				
				HashMap<String, Object> queryParams = new HashMap<String, Object>();
				queryParams.put("=,name", name);
				queryParams.put("=,createUser", user.getUsername());
				Integer classesOnlineCount = publicService.getClassesOnlineCount(queryParams);
				
				List<ClassesOnline> config2 = publicService.getClassesOnline(queryParams, 1, classesOnlineCount);
				queryParams=null;
				boolean flag=true;
				if(config2!=null&& config2.size()>0){
					for (ClassesOnline config : config2) {
						if(!config.getId().equals(Integer.parseInt(id))){
							flag=false;
							break;
						}
					}
				}
				
				if(!flag){
					r.put("result", "fail");
					r.put("msg", "网班已存在");
				}else{
					
					DyLogAnnotations.alterAnnotationOn(method, BusinessType.UPDATE,"编辑-网班");
					
					ClassesOnline classesOnline = publicService.findClassesOnline(Integer.parseInt(id));
					classesOnline.setCover(cover==null?null:cover.replace(FILESERVER, "").replace(FILEPATH, "").replace("//", "/"));
					classesOnline.setDescription(description);
					classesOnline.setName(name);
					classesOnline.setStatus("0");
					classesOnline.setTag(tag);
					classesOnline.setUserIds(userIds);
					classesOnline.setAuditType("0");
					baseService.editClassesOnline(classesOnline);
					auditAdd("0", null, null, "", classesOnline.getId(), "0", user.getId(), user.getUsername(), "2");
					r.put("result", "success");
					r.put("msg", "保存成功");
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="新增-网班评价",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("classesOnlineCommentAddUpdate")
	@ResponseBody
	public void classesOnlineCommentAddUpdate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		String name1 = Thread.currentThread().getStackTrace()[1].getMethodName();
		Method method = this.getClass().getMethod(name1, HttpServletRequest.class,HttpServletResponse.class);
		
		String id = request.getParameter("id");
		String memberId = request.getParameter("memberId");
		String content = request.getParameter("content");
		String telephone = request.getParameter("telephone");
		String feedback = request.getParameter("feedback");
		String classesOnlineId = request.getParameter("classesOnlineId");
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			if(id==null ||"".equals(id)){//新增
				
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.INSERT,"新增-网班评论");
				
				ClassesOnlineComment classesOnlineComment = new ClassesOnlineComment();
				classesOnlineComment.setClassesOnlineId(Integer.parseInt(classesOnlineId));
				classesOnlineComment.setContent(content);
				classesOnlineComment.setCreateTime(DateUtils.getDateTime());
				classesOnlineComment.setFeedback(feedback);
				classesOnlineComment.setMemberId(Integer.parseInt(memberId));
				classesOnlineComment.setTelephone(telephone);
				baseService.saveClassesOnlineComment(classesOnlineComment);
			}else{//更新
				
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.UPDATE,"编辑-网班评论");
				
				ClassesOnlineComment classesOnlineComment = publicService.findClassesOnlineComment(Integer.parseInt(id));
				classesOnlineComment.setClassesOnlineId(Integer.parseInt(classesOnlineId));
				classesOnlineComment.setContent(content);
				classesOnlineComment.setFeedback(feedback);
				classesOnlineComment.setMemberId(Integer.parseInt(memberId));
				classesOnlineComment.setTelephone(telephone);
				baseService.editClassesOnlineComment(classesOnlineComment);
			}
			r.put("result", "success");
			r.put("msg", "保存成功");
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="新增-网班评价反馈",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("classesOnlineCommentFeedbackSave")
	@ResponseBody
	public void classesOnlineCommentFeedbackSave(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String id = request.getParameter("id");
		String feedback = request.getParameter("feedback");
		
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			if(id!=null &&!"".equals(id)){//新增
				ClassesOnlineComment classesOnlineComment = publicService.findClassesOnlineComment(Integer.parseInt(id));
				classesOnlineComment.setFeedback(feedback);
				baseService.editClassesOnlineComment(classesOnlineComment);
				r.put("result", "success");
				r.put("msg", "保存成功");
			}else{
				r.put("result", "fail");
				r.put("msg", "保存失败");
			}
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="新增-收藏",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("collectAddUpdate")
	@ResponseBody
	public void collectAddUpdate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		String name1 = Thread.currentThread().getStackTrace()[1].getMethodName();
		Method method = this.getClass().getMethod(name1, HttpServletRequest.class,HttpServletResponse.class);
		
		String id = request.getParameter("id");
		String memberId = request.getParameter("memberId");
		String type = request.getParameter("type");
		String resourceId = request.getParameter("resourceId");
		
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			if(id==null ||"".equals(id)){//新增
				
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.INSERT,"新增-收藏");
				
				Collect collect = new Collect();
				collect.setCreateTime(DateUtils.getDateTime());
				collect.setMemberId(Integer.parseInt(memberId));
				collect.setResourceId(Integer.parseInt(resourceId));
				collect.setType(type);
				baseService.saveCollect(collect);
			}else{//更新
				
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.UPDATE,"编辑-收藏");
				
				Collect collect = publicService.findCollect(Integer.parseInt(id));
				collect.setMemberId(Integer.parseInt(memberId));
				collect.setResourceId(Integer.parseInt(resourceId));
				collect.setType(type);
				baseService.editCollect(collect);
			}
			r.put("result", "success");
			r.put("msg", "保存成功");
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="新增-意见",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("commentAddUpdate")
	@ResponseBody
	public void commentAddUpdate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		String name1 = Thread.currentThread().getStackTrace()[1].getMethodName();
		Method method = this.getClass().getMethod(name1, HttpServletRequest.class,HttpServletResponse.class);
		
		String id = request.getParameter("id");
		String memberId = request.getParameter("memberId");
		String telephone = request.getParameter("telephone");
		String content = request.getParameter("content");
		String feedback = request.getParameter("feedback");
		User user = publicService.findUser((Integer) request.getSession().getAttribute("userid"));
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			if(id==null ||"".equals(id)){//新增
				
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.INSERT,"新增-意见");
				
				Comment comment = new Comment();
				comment.setCreateTime(DateUtils.getDateTime());
				comment.setContent(content);
				comment.setCreateUser(user.getUsername());
				comment.setFeedback(feedback);
				comment.setMemberId(Integer.parseInt(memberId));
				comment.setStatus(0);
				comment.setTelephone(telephone);
				baseService.saveComment(comment);
			}else{//更新
				
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.UPDATE,"编辑-意见");
				
				Comment comment = publicService.findComment(Integer.parseInt(id));
				comment.setFeedback(feedback);
				comment.setStatus(1);
				comment.setTelephone(telephone);
				baseService.editComment(comment);
			}
			r.put("result", "success");
			r.put("msg", "保存成功");
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="新增-配置",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("configAddUpdate")
	@ResponseBody
	public void configAddUpdate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		String name1 = Thread.currentThread().getStackTrace()[1].getMethodName();
		Method method = this.getClass().getMethod(name1, HttpServletRequest.class,HttpServletResponse.class);
		
		String id = request.getParameter("id");
		String nameCn = request.getParameter("nameCn");
		String nameEn = request.getParameter("nameEn");
		String nameValue = request.getParameter("nameValue");
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			if(id==null ||"".equals(id)){//新增
				
				HashMap<String, Object> queryParams = new HashMap<String, Object>();
				queryParams.put("=,nameCn", nameCn);
				Integer categoryCount = publicService.getConfigCount(queryParams);
				queryParams=null;
				if(categoryCount!=null && categoryCount>0){
					r.put("result", "fail");
					r.put("msg", "配置描述名已存在");
				}else{
					queryParams = new HashMap<String, Object>();
					queryParams.put("=,nameEn", nameEn);
					Integer categoryCount1 = publicService.getConfigCount(queryParams);
					queryParams=null;
					if(categoryCount1!=null && categoryCount1>0){
						r.put("result", "fail");
						r.put("msg", "配置名已存在");
					}else{
						DyLogAnnotations.alterAnnotationOn(method, BusinessType.INSERT,"新增-配置");
						Config config = new Config();
						config.setNameCn(nameCn);
						config.setNameEn(nameEn);
						config.setNameValue(nameValue);
						baseService.saveConfig(config);
						r.put("result", "success");
						r.put("msg", "保存成功");
					}
				}
				
				
			}else{//更新
				
				HashMap<String, Object> queryParams = new HashMap<String, Object>();
				queryParams.put("=,nameCn", nameCn);
				Integer categoryCount = publicService.getConfigCount(queryParams);
				List<Config> config2 = publicService.getConfig(queryParams, 1, categoryCount);
				queryParams=null;
				boolean flag=true;
				if(config2!=null&& config2.size()>0){
					for (Config config : config2) {
						if(!config.getId().equals(Integer.parseInt(id))){
							flag=false;
							break;
						}
					}
				}
				
				if(!flag){
					r.put("result", "fail");
					r.put("msg", "配置描述名已存在");
				}else{
					queryParams = new HashMap<String, Object>();
					queryParams.put("=,nameEn", nameEn);
					Integer categoryCount1 = publicService.getConfigCount(queryParams);
					List<Config> config3 = publicService.getConfig(queryParams, 1, categoryCount1);
					queryParams=null;
					flag=true;
					if(config3!=null&& config3.size()>0){
						for (Config config : config3) {
							if(!config.getId().equals(Integer.parseInt(id))){
								flag=false;
								break;
							}
						}
					}
					if(!flag){
						r.put("result", "fail");
						r.put("msg", "配置名已存在");
					}else{
						DyLogAnnotations.alterAnnotationOn(method, BusinessType.UPDATE,"编辑-配置");
						Config config = publicService.findConfig(Integer.parseInt(id));
						config.setNameCn(nameCn);
						config.setNameEn(nameEn);
						config.setNameValue(nameValue);
						baseService.editConfig(config);
						r.put("result", "success");
						r.put("msg", "保存成功");
					}
				}
			}
			
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="新增-课程",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("courseAddUpdate")
	@ResponseBody
	public void courseAddUpdate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		String name1 = Thread.currentThread().getStackTrace()[1].getMethodName();
		Method method = this.getClass().getMethod(name1, HttpServletRequest.class,HttpServletResponse.class);
		
		String id = request.getParameter("id");
		String name = request.getParameter("name");
		String categoryId = request.getParameter("categoryId");
		String grade = request.getParameter("grade");
		String description = request.getParameter("description");
		String tag = request.getParameter("tag");
		String cover = request.getParameter("cover");
		String userIds = request.getParameter("userIds");
		
		if(description!=null){
			description=description.replace(" src=\""+FILESERVER, " src=\"").replace(" src=\""+FILEPATH, " src=\"").replace(" src=\"//", " src=\"/");
		}
		
		User user = publicService.findUser((Integer) request.getSession().getAttribute("userid"));
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			if(id==null ||"".equals(id)){//新增
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.INSERT,"新增-课程");
				
				HashMap<String, Object> queryParams = new HashMap<String, Object>();
				queryParams.put("=,name", name);
				queryParams.put("=,categoryId", categoryId);
				queryParams.put("=,grade", grade);
				queryParams.put("=,createUser", user.getUsername());
				Integer courseCount = publicService.getCourseCount(queryParams);
				List<Course> course2 = publicService.getCourse(queryParams , 1, courseCount);
				if(course2!=null && course2.size()>0){
					r.put("result", "fail");
					r.put("msg", "有类似课程内容");
				}else{
					Course course = new Course();
					course.setCategoryId(Integer.parseInt(categoryId));
					course.setCover(cover==null?null:cover.replace(FILEPATH, "").replace(FILESERVER,""));
					course.setCreateTime(DateUtils.getDateTime());
					course.setCreateUser(user.getUsername());
					course.setDescription(description);
					course.setGrade(grade);
					course.setName(name);
					course.setStatus(0);
					course.setTag(tag);
					course.setUserIds(userIds);
					course.setAuditType("0");
					Course saveCourse = baseService.saveCourse(course);
					auditAdd("0", null, null, "", saveCourse.getId(), "0", user.getId(), user.getUsername(), "0");
					r.put("result", "success");
					r.put("msg", "保存成功");
				}
			}else{//更新
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.UPDATE,"编辑-课程");
				Course course = publicService.findCourse(Integer.parseInt(id));
				
				HashMap<String, Object> queryParams = new HashMap<String, Object>();
				queryParams.put("=,name", name);
				queryParams.put("=,categoryId", categoryId);
				queryParams.put("=,grade", grade);
				queryParams.put("=,createUser", user.getUsername());
				Integer courseCount = publicService.getCourseCount(queryParams);
				List<Course> course2 = publicService.getCourse(queryParams , 1, courseCount);
				boolean flag=true;
				if(course2!=null&& course2.size()>0){
					for (Course c : course2) {
						if(!c.getId().equals(Integer.parseInt(id))){
							flag=false;
							break;
						}
					}
				}
					
				if(!flag){
					r.put("result", "fail");
					r.put("msg", "有类似课程内容");
				}else{
					
					course.setCategoryId(Integer.parseInt(categoryId));
					course.setCover(cover==null?null:cover.replace(FILEPATH, "").replace(FILESERVER,""));
					course.setDescription(description);
					course.setGrade(grade);
					course.setName(name);
					course.setStatus(0);
					course.setTag(tag);
					course.setUserIds(userIds);
					course.setAuditType("0");
					baseService.editCourse(course);
					auditAdd("0", null, null, "", course.getId(), "0", user.getId(), user.getUsername(), "0");
					r.put("result", "success");
					r.put("msg", "保存成功");
				}
			}
			
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="新增-课程评价",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("courseCommentAddUpdate")
	@ResponseBody
	public void courseCommentAddUpdate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		String name1 = Thread.currentThread().getStackTrace()[1].getMethodName();
		Method method = this.getClass().getMethod(name1, HttpServletRequest.class,HttpServletResponse.class);
		
		String id = request.getParameter("id");
		String memberId = request.getParameter("memberId");
		String content = request.getParameter("content");
		String telephone = request.getParameter("telephone");
		String feedback = request.getParameter("feedback");
		String courseId = request.getParameter("courseId");

		HashMap<String, String>r=new HashMap<String, String>();
		try {
			if(id==null ||"".equals(id)){//新增
				
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.INSERT,"新增-课程评论");
				
				CourseComment courseComment = new CourseComment();
				courseComment.setContent(content);
				courseComment.setCourseId(Integer.parseInt(courseId));
				courseComment.setCreateTime(DateUtils.getDateTime());
				courseComment.setFeedback(feedback);
				courseComment.setMemberId(Integer.parseInt(memberId));
				courseComment.setTelephone(telephone);
				baseService.saveCourseComment(courseComment);
			}else{//更新
				
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.UPDATE,"编辑-课程评论");
				
				CourseComment courseComment = publicService.findCourseComment(Integer.parseInt(id));
				courseComment.setContent(content);
				courseComment.setCourseId(Integer.parseInt(courseId));
				courseComment.setFeedback(feedback);
				courseComment.setMemberId(Integer.parseInt(memberId));
				courseComment.setTelephone(telephone);
				baseService.editCourseComment(courseComment);
			}
			r.put("result", "success");
			r.put("msg", "保存成功");
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="新增-课程评价反馈",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("courseCommentFeedbackSave")
	@ResponseBody
	public void courseCommentFeedbackSave(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String id = request.getParameter("id");
		String feedback = request.getParameter("feedback");
		
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			if(id!=null &&!"".equals(id)){//新增
				CourseComment courseComment = publicService.findCourseComment(Integer.parseInt(id));
				courseComment.setFeedback(feedback);
				baseService.editCourseComment(courseComment);
				r.put("result", "success");
				r.put("msg", "保存成功");
			}else{
				r.put("result", "fail");
				r.put("msg", "保存失败");
			}
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="新增-课程组卷",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("courseQuestionAddUpdate")
	@ResponseBody
	public void courseQuestionAddUpdate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String courseId = request.getParameter("courseId");
		String questionId = request.getParameter("questionId");
		String paperId = request.getParameter("paperId");
		
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			
			HashMap<String, Object> queryParams = new HashMap<String, Object>();
			queryParams.put("=,courseId", courseId);
			queryParams.put("=,questionId", questionId);
			queryParams.put("=,paperId", paperId);
			Integer courseQuestionCount = publicService.getCourseQuestionCount(queryParams);
			if(courseQuestionCount>0){
				r.put("result", "tail");
				r.put("msg", "题目已经存在");
			}else{
				CourseQuestion courseQuestion = new CourseQuestion();
				courseQuestion.setCourseId(Integer.parseInt(courseId));
				courseQuestion.setQuestionId(Integer.parseInt(questionId));
				courseQuestion.setPaperId(Integer.parseInt(paperId));
				baseService.saveCourseQuestion(courseQuestion);
				r.put("result", "success");
				r.put("msg", "添加成功");
			}
			
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "添加失败");
		}
		
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="新增-直播",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("liveAddUpdate")
	@ResponseBody
	public void liveAddUpdate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		String name1 = Thread.currentThread().getStackTrace()[1].getMethodName();
		Method method = this.getClass().getMethod(name1, HttpServletRequest.class,HttpServletResponse.class);
		
		String id = request.getParameter("id");
		String name = request.getParameter("name");
		String classesOnlineId = request.getParameter("classesOnlineId");
		String liveSource = request.getParameter("liveSource");
		String tag = request.getParameter("tag");
		String price = request.getParameter("price");
		String cover = request.getParameter("cover");
		String liveStart = request.getParameter("liveStart");
		String liveEnd = request.getParameter("liveEnd");
		String description = request.getParameter("description");
		String liveStatus = request.getParameter("liveStatus");

		User user = publicService.findUser((Integer) request.getSession().getAttribute("userid"));
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			if(id==null ||"".equals(id)){//新增
				HashMap<String, Object> queryParams = new HashMap<String, Object>();
				queryParams.put("=,name", name);
				queryParams.put("=,classesOnlineId", classesOnlineId);
				Integer liveCount = publicService.getLiveCount(queryParams);
				if(liveCount!=null && liveCount>0){
					r.put("result", "fail");
					r.put("msg", "直播已存在");
				}else{
					DyLogAnnotations.alterAnnotationOn(method, BusinessType.INSERT,"新增-直播");
					
					Live live = new Live();
					live.setCreateTime(DateUtils.getDateTime());
					live.setCreateUser(user.getUsername());
					live.setClassesOnlineId(Integer.parseInt(classesOnlineId));
					live.setCover(cover==null?null:cover.replace(FILESERVER, "").replace(FILEPATH, "").replace("//", "/"));
					live.setDescription(description);
					live.setLiveEnd(liveEnd);
					live.setLiveSource(liveSource);
					live.setLiveStart(liveStart);
					live.setName(name);
					live.setPrice(price);
					live.setStatus(0);
					live.setAuditType("0");
					live.setTag(tag);
					live.setLiveStatus(liveStatus);
					Live saveLive = baseService.saveLive(live);
					auditAdd("0", null, null, "", saveLive.getId(), "0", user.getId(), user.getUsername(), "3");
					r.put("result", "success");
					r.put("msg", "保存成功");
				}
				
			}else{//更新
				
				HashMap<String, Object> queryParams = new HashMap<String, Object>();
				queryParams.put("=,name", name);
				queryParams.put("=,classesOnlineId", classesOnlineId);
				Integer liveCount = publicService.getLiveCount(queryParams);
				
				List<Live> config2 = publicService.getLive(queryParams, 1, liveCount);
				queryParams=null;
				boolean flag=true;
				if(config2!=null&& config2.size()>0){
					for (Live config : config2) {
						if(!config.getId().equals(Integer.parseInt(id))){
							flag=false;
							break;
						}
					}
				}
				
				if(!flag){
					r.put("result", "fail");
					r.put("msg", "直播已存在");
				}else{
					DyLogAnnotations.alterAnnotationOn(method, BusinessType.UPDATE,"编辑-直播");
					
					Live live = publicService.findLive(Integer.parseInt(id));
					live.setClassesOnlineId(Integer.parseInt(classesOnlineId));
					live.setCover(cover==null?null:cover.replace(FILESERVER, "").replace(FILEPATH, "").replace("//", "/"));
					live.setDescription(description);
					live.setLiveEnd(liveEnd);
					live.setLiveSource(liveSource);
					live.setLiveStart(liveStart);
					live.setName(name);
					live.setPrice(price);
					//live.setStatus(0);
					live.setTag(tag);
					//live.setAuditType("0");toulan
					if(user.getType()!=0){//type==0 后台用户
						live.setStatus(0);
						live.setAuditType("0");
					}
					live.setLiveStatus(liveStatus);
					baseService.editLive(live);
					auditAdd("0", null, null, "", live.getId(), "0", user.getId(), user.getUsername(), "3");
					r.put("result", "success");
					r.put("msg", "保存成功");
				}
			}
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="新增-直播组卷",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("liveQuestionAddUpdate")
	@ResponseBody
	public void liveQuestionAddUpdate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String liveId = request.getParameter("liveId");
		String questionId = request.getParameter("questionId");
		String paperId = request.getParameter("paperId");
		
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			HashMap<String, Object> queryParams = new HashMap<String, Object>();
			queryParams.put("=,liveId", liveId);
			queryParams.put("=,questionId", questionId);
			queryParams.put("=,paperId", paperId);
			Integer liveQuestionCount = publicService.getLiveQuestionCount(queryParams);
			if(liveQuestionCount>0){
				r.put("result", "tail");
				r.put("msg", "题目已经存在");
			}else{
				LiveQuestion liveQuestion = new LiveQuestion();
				liveQuestion.setLiveId(Integer.parseInt(liveId));
				liveQuestion.setQuestionId(Integer.parseInt(questionId));
				liveQuestion.setPaperId(Integer.parseInt(paperId));
				baseService.saveLiveQuestion(liveQuestion);
				r.put("result", "success");
				r.put("msg", "保存成功");
			}
			
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="新增-前台用户",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("memberAddUpdate")
	@ResponseBody
	public void memberAddUpdate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		String name1 = Thread.currentThread().getStackTrace()[1].getMethodName();
		Method method = this.getClass().getMethod(name1, HttpServletRequest.class,HttpServletResponse.class);
		
		String id = request.getParameter("id");
		String username = request.getParameter("username");
		String password = request.getParameter("password");
		String realName = request.getParameter("realName");
		String nickName = request.getParameter("nickName");
		String type = request.getParameter("type");
		String avatarImg = request.getParameter("avatarImg");
		String status = request.getParameter("status");
		String email = request.getParameter("email");
		String telephone = request.getParameter("telephone");
		String gender = request.getParameter("gender");
		String signature = request.getParameter("signature");
		String description = request.getParameter("description");

		//User user = publicService.findUser((Integer) request.getSession().getAttribute("userid"));
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			if(id==null ||"".equals(id)){//新增
				
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.INSERT,"新增-前台用户");
				
				Member member = new  Member();
				member.setAvatarImg(avatarImg==null?null:avatarImg.replace(FILESERVER, "").replace(FILEPATH, "").replace("//", "/"));
				member.setCreateTime(DateUtils.getDateTime());
				member.setDescription(description);
				member.setEmail(email);
				member.setGender(Integer.parseInt(gender));
				member.setNickName(nickName);
				member.setPassword(MD5.string2MD5(password));
				member.setRealName(realName);
				member.setSignature(signature);
				member.setStatus(Integer.parseInt(status));
				member.setTelephone(telephone);
				member.setType(Integer.parseInt(type));
				member.setUsername(username);
				baseService.saveMember(member);
			}else{//更新
				
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.UPDATE,"编辑-前台用户");
				
				Member member = publicService.findMember(Integer.parseInt(id));
				member.setAvatarImg(avatarImg==null?null:avatarImg.replace(FILESERVER, "").replace(FILEPATH, "").replace("//", "/"));
				member.setDescription(description);
				member.setEmail(email);
				member.setGender(Integer.parseInt(gender));
				member.setNickName(nickName);
				member.setPassword(MD5.string2MD5(password));
				member.setRealName(realName);
				member.setSignature(signature);
				member.setStatus(Integer.parseInt(status));
				member.setTelephone(telephone);
				member.setType(Integer.parseInt(type));
				member.setUsername(username);
				baseService.editMember(member);
			}
			r.put("result", "success");
			r.put("msg", "保存成功");
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="审核-前台用户",businessType=BusinessType.GRANT,operatorType=OperatorType.MANAGE)
	@RequestMapping("memberShenhe")
	@ResponseBody
	public void memberShenhe(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String ids = request.getParameter("ids");
		String type = request.getParameter("type");
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			if(ids!=null && !"".equals(ids)&&type!=null&&!"".equals(type)){
				String[] splits = ids.split(";");
				for (String string : splits) {
					if(!"".equals(string)){
						Member member = publicService.findMember(Integer.parseInt(string));
						if(member!=null){
							member.setStatus(Integer.parseInt(type));
							baseService.editMember(member);
							member=null;
						}
					}
				}
			}
			r.put("result", "success");
			r.put("msg", "保存成功");
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="审核-后台用户",businessType=BusinessType.GRANT,operatorType=OperatorType.MANAGE)
	@RequestMapping("userShenhe")
	@ResponseBody
	public void userShenhe(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String ids = request.getParameter("ids");
		String type = request.getParameter("type");
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			if(ids!=null && !"".equals(ids)&&type!=null&&!"".equals(type)){
				String[] splits = ids.split(";");
				for (String string : splits) {
					if(!"".equals(string)){
						User user = publicService.findUser(Integer.parseInt(string));
						if(user!=null){
							user.setStatus(Integer.parseInt(type));
							baseService.editUser(user);
							user=null;
						}
					}
				}
			}
			r.put("result", "success");
			r.put("msg", "保存成功");
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="新增-消息",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("messageAddUpdate")
	@ResponseBody
	public void messageAddUpdate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		String name1 = Thread.currentThread().getStackTrace()[1].getMethodName();
		Method method = this.getClass().getMethod(name1, HttpServletRequest.class,HttpServletResponse.class);
		
		String id = request.getParameter("id");
		String title = request.getParameter("title");
		String content = request.getParameter("content");
		String cover = request.getParameter("cover");

		if(content!=null){
			content=content.replace(" src=\""+FILESERVER, " src=\"").replace(" src=\""+FILEPATH, " src=\"").replace(" src=\"//", " src=\"/");
		}
		
		User user = publicService.findUser((Integer) request.getSession().getAttribute("userid"));
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			if(id==null ||"".equals(id)){//新增
				
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.INSERT,"新增-消息");
				
				Message message = new  Message();
				message.setCreateTime(DateUtils.getDateTime());
				message.setCreateUser(user.getUsername());
				message.setContent(content);
				message.setCover(cover==null?null:cover.replace(FILESERVER, "").replace(FILEPATH, "").replace("//", "/"));
				message.setStatus(0);
				message.setTitle(title);
				baseService.saveMessage(message);
			}else{//更新
				
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.UPDATE,"编辑-消息");
				
				Message message = publicService.findMessage(Integer.parseInt(id));
				message.setContent(content);
				message.setCover(cover==null?null:cover.replace(FILESERVER, "").replace(FILEPATH, "").replace("//", "/"));
				message.setStatus(0);
				message.setTitle(title);
				baseService.editMessage(message);
			}
			r.put("result", "success");
			r.put("msg", "保存成功");
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="发布-消息",businessType=BusinessType.SUBMIT,operatorType=OperatorType.MANAGE)
	@RequestMapping("messageSubmit")
	@ResponseBody
	public void messageBatchSubmit(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String ids = request.getParameter("ids");
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			if(ids!=null && !"".equals(ids)){
				String[] splits = ids.split(";");
				for (String string : splits) {
					if(!"".equals(string)){
						Message message = publicService.findMessage(Integer.parseInt(string));
						message.setStatus(1);
						baseService.editMessage(message);
						message=null;
					}
				}
			}
			r.put("result", "success");
			r.put("msg", "保存成功");
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="新增-微课",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("onlineAddUpdate")
	@ResponseBody
	public void onlineAddUpdate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		String name1 = Thread.currentThread().getStackTrace()[1].getMethodName();
		Method method = this.getClass().getMethod(name1, HttpServletRequest.class,HttpServletResponse.class);
		
		String id = request.getParameter("id");
		String name = request.getParameter("name");
		String type = request.getParameter("type");
		String videoPath = request.getParameter("videoPath");
		String pptPath = request.getParameter("pptPath");
		String description = request.getParameter("description");
		String courseId = request.getParameter("courseId");
		String tag = request.getParameter("tag");
		String price = request.getParameter("price");
		String pdfPath = request.getParameter("pdfPath");
		String pptFilePath = request.getParameter("pptFilePath");
		String pdfFilePath = request.getParameter("pdfFilePath");

		User user = publicService.findUser((Integer) request.getSession().getAttribute("userid"));
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			if(id==null ||"".equals(id)){//新增
				
				HashMap<String, Object> queryParams = new HashMap<String, Object>();
				queryParams.put("=,name", name);
				queryParams.put("=,courseId", courseId);
				Integer categoryCount = publicService.getOnlineCount(queryParams);
				if(categoryCount!=null && categoryCount>0){
					r.put("result", "fail");
					r.put("msg", "微课已存在");
				}else{
					DyLogAnnotations.alterAnnotationOn(method, BusinessType.INSERT,"新增-微课");
					
					Online online = new  Online();
					online.setCreateTime(DateUtils.getDateTime());
					online.setCreateUser(user.getUsername());
					online.setCourseId(Integer.parseInt(courseId));
					online.setDescription(description);
					online.setName(name);
					online.setPdfPath(pdfPath);
					online.setPptPath(pptPath);
					online.setPrice(price);
					online.setStatus(0);
					online.setTag(tag);
					online.setType(Integer.parseInt(type));
					online.setVideoPath(videoPath);
					online.setPptFilePath(pptFilePath==null?null:pptFilePath.replace(FILESERVER, "").replace(FILEPATH, "").replace("//", "/"));
					online.setPdfFilePath(pdfFilePath==null?null:pdfFilePath.replace(FILESERVER, "").replace(FILEPATH, "").replace("//", "/"));
					online.setAuditType("0");
					Online saveOnline = baseService.saveOnline(online);
					auditAdd("0", null, null, "", saveOnline.getId(), "0", user.getId(), user.getUsername(), "4");
					
					r.put("result", "success");
					r.put("msg", "保存成功");
				}
				
			}else{//更新
				
				HashMap<String, Object> queryParams = new HashMap<String, Object>();
				queryParams.put("=,name", name);
				queryParams.put("=,courseId", courseId);
				Integer categoryCount = publicService.getOnlineCount(queryParams);
				
				List<Online> config2 = publicService.getOnline(queryParams, 1, categoryCount);
				queryParams=null;
				boolean flag=true;
				if(config2!=null&& config2.size()>0){
					for (Online config : config2) {
						if(!config.getId().equals(Integer.parseInt(id))){
							flag=false;
							break;
						}
					}
				}
				
				if(!flag){
					r.put("result", "fail");
					r.put("msg", "微课已存在");
				}else{
					
					DyLogAnnotations.alterAnnotationOn(method, BusinessType.UPDATE,"编辑-微课");
					
					Online online = publicService.findOnline(Integer.parseInt(id));
					online.setCourseId(Integer.parseInt(courseId));
					online.setDescription(description);
					online.setName(name);
					online.setPdfPath(pdfPath);
					online.setPptPath(pptPath);
					online.setPrice(price);
					online.setTag(tag);
					online.setType(Integer.parseInt(type));
					online.setVideoPath(videoPath);
					online.setPptFilePath(pptFilePath==null?null:pptFilePath.replace(FILESERVER, "").replace(FILEPATH, "").replace("//", "/"));
					online.setPdfFilePath(pdfFilePath==null?null:pdfFilePath.replace(FILESERVER, "").replace(FILEPATH, "").replace("//", "/"));
					if(user.getType()!=0){//type==0 后台用户
						online.setStatus(0);
						online.setAuditType("0");
					}
					baseService.editOnline(online);
					auditAdd("0", null, null, "", online.getId(), "0", user.getId(), user.getUsername(), "4");
					r.put("result", "success");
					r.put("msg", "保存成功");
				}
			}
			
		} catch (Exception e) {
			e.printStackTrace();
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="新增-微课组卷",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("onlineQuestionAddUpdate")
	@ResponseBody
	public void onlineQuestionAddUpdate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String onlineId = request.getParameter("onlineId");
		String questionId = request.getParameter("questionId");
		String paperId = request.getParameter("paperId");
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			HashMap<String, Object> queryParams = new HashMap<String, Object>();
			queryParams.put("=,onlineId", onlineId);
			queryParams.put("=,questionId", questionId);
			queryParams.put("=,paperId", paperId);
			Integer onlineQuestionCount = publicService.getOnlineQuestionCount(queryParams);
			if(onlineQuestionCount>0){
				r.put("result", "tail");
				r.put("msg", "题目已经存在");
			}else{
				OnlineQuestion onlineQuestion = new OnlineQuestion();
				onlineQuestion.setOnlineId(Integer.parseInt(onlineId));
				onlineQuestion.setQuestionId(Integer.parseInt(questionId));
				onlineQuestion.setPaperId(Integer.parseInt(paperId));
				baseService.saveOnlineQuestion(onlineQuestion);
				r.put("result", "success");
				r.put("msg", "保存成功");
			}
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="新增-订单",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("orderAddUpdate")
	@ResponseBody
	public void orderAddUpdate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		String name1 = Thread.currentThread().getStackTrace()[1].getMethodName();
		Method method = this.getClass().getMethod(name1, HttpServletRequest.class,HttpServletResponse.class);
		
		String id = request.getParameter("id");
		String memberId = request.getParameter("memberId");
		String payWay = request.getParameter("payWay");
		String status = request.getParameter("status");
		String payPrice = request.getParameter("payPrice");
		String createIpAddress = request.getParameter("createIpAddress");
		String orderNumber = request.getParameter("orderNumber");
		String type = request.getParameter("type");
		
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			if(id==null ||"".equals(id)){//新增
				
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.INSERT,"新增-订单");
				
				Order order = new  Order();
				order.setCreateTime(DateUtils.getDateTime());
				order.setCreateIpAddress(createIpAddress);
				order.setMemberId(Integer.parseInt(memberId));
				order.setOrderNumber(orderNumber);
				order.setPayPrice(new BigDecimal(payPrice));
				order.setPayWay(payWay);
				order.setStatus(Integer.parseInt(status));
				order.setType(Integer.parseInt(type));
				baseService.saveOrder(order);
			}else{//更新
				
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.UPDATE,"编辑-订单");
				
				Order order = publicService.findOrder(Integer.parseInt(id));
				order.setCreateIpAddress(createIpAddress);
				order.setMemberId(Integer.parseInt(memberId));
				order.setOrderNumber(orderNumber);
				order.setPayPrice(new BigDecimal(payPrice));
				order.setPayWay(payWay);
				order.setStatus(Integer.parseInt(status));
				order.setType(Integer.parseInt(type));
				baseService.editOrder(order);
			}
			r.put("result", "success");
			r.put("msg", "保存成功");
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="新增-题目",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("questionAddUpdate")
	@ResponseBody
	public void questionAddUpdate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		String name1 = Thread.currentThread().getStackTrace()[1].getMethodName();
		Method method = this.getClass().getMethod(name1, HttpServletRequest.class,HttpServletResponse.class);
		
		String id = request.getParameter("id");
		String name = request.getParameter("name");
		String questionDatabaseId = request.getParameter("questionDatabaseId");
		String type = request.getParameter("type");
		String analysis = request.getParameter("analysis");
		String wenda = request.getParameter("wenda");
		String options = request.getParameter("options");
		String answer = request.getParameter("answer");

		User user = publicService.findUser((Integer) request.getSession().getAttribute("userid"));
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			if(id==null ||"".equals(id)){//新增
				
				HashMap<String, Object> queryParams = new HashMap<String, Object>();
				queryParams.put("=,name", name);
				queryParams.put("=,type", type);
				queryParams.put("=,questionDatabaseId", questionDatabaseId);
				Integer categoryCount = publicService.getQuestionCount(queryParams);
				if(categoryCount!=null && categoryCount>0){
					r.put("result", "fail");
					r.put("msg", "题目已存在");
				}else{
					
					DyLogAnnotations.alterAnnotationOn(method, BusinessType.INSERT,"新增-题目");
					
					Question question = new  Question();
					question.setCreateTime(DateUtils.getDateTime());
					question.setCreateUser(user.getUsername());
					question.setAnalysis(analysis==null?null:analysis.replace(FILESERVER, "").replace(FILEPATH, "").replace("//", "/"));
					if("0".equals(type)){
						question.setAnswer0(answer);
					}
					if("1".equals(type)){
						question.setAnswer1(answer);
					}
					if("2".equals(type)){
						question.setAnswer2(wenda);
					}
					question.setOptions(options);
					question.setName(name);
					question.setQuestionDatabaseId(Integer.parseInt(questionDatabaseId));
					question.setStatus(0);
					question.setType(Integer.parseInt(type));
					question.setAuditType("0");
					Question saveQuestion = baseService.saveQuestion(question);
					auditAdd("0", null, null, "", saveQuestion.getId(), "0", user.getId(), user.getUsername(), "1");
					r.put("result", "success");
					r.put("msg", "保存成功");
				}
				
			}else{//更新
				
				HashMap<String, Object> queryParams = new HashMap<String, Object>();
				queryParams.put("=,name", name);
				queryParams.put("=,type", type);
				queryParams.put("=,questionDatabaseId", questionDatabaseId);
				Integer categoryCount = publicService.getQuestionCount(queryParams);
				
				List<Question> config2 = publicService.getQuestion(queryParams, 1, categoryCount);
				queryParams=null;
				boolean flag=true;
				if(config2!=null&& config2.size()>0){
					for (Question config : config2) {
						if(!config.getId().equals(Integer.parseInt(id))){
							flag=false;
							break;
						}
					}
				}
				
				if(!flag){
					r.put("result", "fail");
					r.put("msg", "题目已存在");
				}else{
					DyLogAnnotations.alterAnnotationOn(method, BusinessType.UPDATE,"编辑-题目");
					
					Question question = publicService.findQuestion(Integer.parseInt(id));
					question.setAnalysis(analysis==null?null:analysis.replace(FILESERVER, "").replace(FILEPATH, "").replace("//", "/"));
					if("0".equals(type)){
						question.setAnswer0(answer);
					}
					if("1".equals(type)){
						question.setAnswer1(answer);
					}
					if("2".equals(type)){
						question.setAnswer2(wenda);
					}
					question.setOptions(options);
					question.setName(name);
					question.setQuestionDatabaseId(Integer.parseInt(questionDatabaseId));
					question.setStatus(0);
					question.setType(Integer.parseInt(type));
					question.setAuditType("0");
					baseService.editQuestion(question);
					auditAdd("0", null, null, "", question.getId(), "0", user.getId(), user.getUsername(), "1");
					r.put("result", "success");
					r.put("msg", "保存成功");
					
				}
				
				
			}
			
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="新增-题库",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("questionDatabaseAddUpdate")
	@ResponseBody
	public void questionDatabaseAddUpdate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		String name1 = Thread.currentThread().getStackTrace()[1].getMethodName();
		Method method = this.getClass().getMethod(name1, HttpServletRequest.class,HttpServletResponse.class);
		
		String id = request.getParameter("id");
		String name = request.getParameter("name");
		String type = request.getParameter("type");
		String tag = request.getParameter("tag");
		String description = request.getParameter("description");

		User user = publicService.findUser((Integer) request.getSession().getAttribute("userid"));
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			if(id==null ||"".equals(id)){//新增
				
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.INSERT,"新增-题库");
				
				HashMap<String, Object> queryParams = new HashMap<String, Object>();
				queryParams.put("=,name", name);
				queryParams.put("=,type", type);
				queryParams.put("=,createUser", user.getUsername());
				Integer courseCount = publicService.getQuestionDatabaseCount(queryParams);
				List<QuestionDatabase> course2 = publicService.getQuestionDatabase(queryParams , 1, courseCount);
				if(course2!=null && course2.size()>0){
					r.put("result", "fail");
					r.put("msg", "有类似题库内容");
				}else{
					QuestionDatabase questionDatabase = new  QuestionDatabase();
					questionDatabase.setCreateTime(DateUtils.getDateTime());
					questionDatabase.setCreateUser(user.getUsername());
					questionDatabase.setName(name);
					questionDatabase.setStatus(0);
					questionDatabase.setTag(tag);
					questionDatabase.setType(type);
					questionDatabase.setDescription(description);
					questionDatabase.setAuditType("0");
					QuestionDatabase saveQuestionDatabase = baseService.saveQuestionDatabase(questionDatabase);
					auditAdd("0", null, null, "", saveQuestionDatabase.getId(), "0", user.getId(), user.getUsername(), "6");
					r.put("result", "success");
					r.put("msg", "保存成功");
				}
			}else{//更新
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.UPDATE,"编辑-题库");
				
				
				HashMap<String, Object> queryParams = new HashMap<String, Object>();
				queryParams.put("=,name", name);
				queryParams.put("=,type", type);
				queryParams.put("=,createUser", user.getUsername());
				queryParams.put("=,createUser", user.getUsername());
				Integer courseCount = publicService.getQuestionDatabaseCount(queryParams);
				List<QuestionDatabase> course2 = publicService.getQuestionDatabase(queryParams , 1, courseCount);
				boolean flag=true;
				if(course2!=null&& course2.size()>0){
					for (QuestionDatabase c : course2) {
						if(!c.getId().equals(Integer.parseInt(id))){
							flag=false;
							break;
						}
					}
				}
					
				if(!flag){
					r.put("result", "fail");
					r.put("msg", "有类似题库内容");
				}else{
					QuestionDatabase questionDatabase = publicService.findQuestionDatabase(Integer.parseInt(id));
					questionDatabase.setName(name);
					questionDatabase.setStatus(0);
					questionDatabase.setTag(tag);
					questionDatabase.setType(type);
					questionDatabase.setDescription(description);
					questionDatabase.setAuditType("0");
					baseService.editQuestionDatabase(questionDatabase);
					auditAdd("0", null, null, "", questionDatabase.getId(), "0", user.getId(), user.getUsername(), "6");
					r.put("result", "success");
					r.put("msg", "保存成功");
				}
				
				
			}
			
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="新增-短视频",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("shortFilmAddUpdate")
	@ResponseBody
	public void shortFilmAddUpdate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		String name1 = Thread.currentThread().getStackTrace()[1].getMethodName();
		Method method = this.getClass().getMethod(name1, HttpServletRequest.class,HttpServletResponse.class);
		
		String id = request.getParameter("id");
		String description = request.getParameter("description");
		String filePath = request.getParameter("filePath");
		String memberId = request.getParameter("memberId");
		String status = request.getParameter("status");
		String telephone = request.getParameter("telephone");
		
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			if(id==null ||"".equals(id)){//新增
				
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.INSERT,"新增-短视频");
				
				ShortFilm shortFilm = new  ShortFilm();
				shortFilm.setCreateTime(DateUtils.getDateTime());
				shortFilm.setDescription(description);
				shortFilm.setFilePath(filePath==null?null:filePath.replace(FILESERVER, "").replace(FILEPATH, "").replace("//", "/"));
				shortFilm.setMemberId(memberId);
				shortFilm.setStatus(0);
				shortFilm.setTelephone(telephone);
				baseService.saveShortFilm(shortFilm);
			}else{//更新
				
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.UPDATE,"编辑-短视频");
				
				ShortFilm shortFilm = publicService.findShortFilm(Integer.parseInt(id));
				shortFilm.setDescription(description);
				shortFilm.setFilePath(filePath==null?null:filePath.replace(FILESERVER, "").replace(FILEPATH, "").replace("//", "/"));
				shortFilm.setMemberId(memberId);
				shortFilm.setStatus(0);
				shortFilm.setTelephone(telephone);
				baseService.editShortFilm(shortFilm);
			}
			r.put("result", "success");
			r.put("msg", "保存成功");
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="启用-短视频",businessType=BusinessType.ENABLE,operatorType=OperatorType.MANAGE)
	@RequestMapping("shortFilmDisOrEnabled")
	@ResponseBody
	public void shortFilmDisOrEnabled(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String ids = request.getParameter("ids");
		String status = request.getParameter("status");
		
		HashMap<String, String>r=new HashMap<String, String>();
		if("0".equals(status)){
			String name1 = Thread.currentThread().getStackTrace()[1].getMethodName();
			Method method = this.getClass().getMethod(name1, HttpServletRequest.class,HttpServletResponse.class);
			DyLogAnnotations.alterAnnotationOn(method, BusinessType.DISENABLE,"禁用-短视频");
		}
		try{
			String[] splits = ids.split(";");
			for (String string : splits) {
				if(!"".equals(string)){
					ShortFilm shortFilm = publicService.findShortFilm(Integer.parseInt(string));
					shortFilm.setStatus(Integer.parseInt(status));
					baseService.editShortFilm(shortFilm);
				}
			}
			r.put("result", "success");
			r.put("msg", "保存成功");
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="新增-短视频评论",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("shortFilmCommentAddUpdate")
	@ResponseBody
	public void shortFilmCommentList(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String id = request.getParameter("id");
		String memberId = request.getParameter("memberId");
		String content = request.getParameter("content");
		String telephone = request.getParameter("telephone");
		String feedback = request.getParameter("feedback");
		String shortFilmId = request.getParameter("shortFilmId");
		
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			if(id==null ||"".equals(id)){//新增
				ShortFilmComment shortFilmComment = new  ShortFilmComment();
				shortFilmComment.setCreateTime(DateUtils.getDateTime());
				shortFilmComment.setContent(content);
				shortFilmComment.setFeedback(feedback);
				shortFilmComment.setMemberId(Integer.parseInt(memberId));
				shortFilmComment.setShortFilmId(Integer.parseInt(shortFilmId));
				shortFilmComment.setTelephone(telephone);
				baseService.saveShortFilmComment(shortFilmComment);
			}else{//更新
				String name1 = Thread.currentThread().getStackTrace()[1].getMethodName();
				Method method = this.getClass().getMethod(name1, HttpServletRequest.class,HttpServletResponse.class);
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.UPDATE,"编辑-短视频评论");
				
				ShortFilmComment shortFilmComment = publicService.findShortFilmComment(Integer.parseInt(id));
				shortFilmComment.setContent(content);
				shortFilmComment.setFeedback(feedback);
				shortFilmComment.setMemberId(Integer.parseInt(memberId));
				shortFilmComment.setShortFilmId(Integer.parseInt(shortFilmId));
				shortFilmComment.setTelephone(telephone);
				baseService.editShortFilmComment(shortFilmComment);
			}
			r.put("result", "success");
			r.put("msg", "保存成功");
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="新增-卷子",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("paperAddUpdate")
	@ResponseBody
	public void paperAddUpdate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		String name1 = Thread.currentThread().getStackTrace()[1].getMethodName();
		Method method = this.getClass().getMethod(name1, HttpServletRequest.class,HttpServletResponse.class);
		
		String id = request.getParameter("id");
		String name = request.getParameter("name");
		String type = request.getParameter("type");
		String description = request.getParameter("description");
		String resourceId = request.getParameter("resourceId");
		String startTime = request.getParameter("startTime");
		String endTime = request.getParameter("endTime");
		
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			if(id==null ||"".equals(id)){//新增
				
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.INSERT,"新增-卷子");
				
				Paper paper = new  Paper();
				paper.setCreateTime(DateUtils.getDateTime());
				paper.setDescription(description);
				paper.setResourceId(resourceId);
				paper.setName(name);
				paper.setType(type);
				paper.setStartTime(startTime);
				paper.setEndTime(endTime);
				baseService.savePaper(paper);
			}else{//更新
				
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.UPDATE,"编辑-卷子");
				
				Paper paper = publicService.findPaper(Integer.parseInt(id));
				paper.setCreateTime(DateUtils.getDateTime());
				paper.setDescription(description);
				paper.setResourceId(resourceId);
				paper.setName(name);
				paper.setType(type);
				paper.setStartTime(startTime);
				paper.setEndTime(endTime);
				baseService.editPaper(paper);
			}
			r.put("result", "success");
			r.put("msg", "保存成功");
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="新增-答案",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
	@RequestMapping("answerAddUpdate")
	@ResponseBody
	public void answerAddUpdate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		String name1 = Thread.currentThread().getStackTrace()[1].getMethodName();
		Method method = this.getClass().getMethod(name1, HttpServletRequest.class,HttpServletResponse.class);
		
		String id = request.getParameter("id");
		String memberId = request.getParameter("memberId");
		String paperId = request.getParameter("paperId");
		String questionId = request.getParameter("questionId");
		String answer = request.getParameter("answer");

		
		
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			if(id==null ||"".equals(id)){//新增
				
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.INSERT,"新增-答案");
				
				Answer answer2 = new  Answer();
				answer2.setCreateTime(DateUtils.getDateTime());
				answer2.setAnswer(answer);
				answer2.setMemberId(Integer.parseInt(memberId));
				answer2.setPaperId(Integer.parseInt(paperId));
				answer2.setQuestionId(Integer.parseInt(questionId));
				baseService.saveAnswer(answer2);
			}else{//更新
				
				DyLogAnnotations.alterAnnotationOn(method, BusinessType.UPDATE,"编辑-答案");
				
				Answer answer2 = publicService.findAnswer(Integer.parseInt(id));
				answer2.setCreateTime(DateUtils.getDateTime());
				answer2.setAnswer(answer);
				answer2.setMemberId(Integer.parseInt(memberId));
				answer2.setPaperId(Integer.parseInt(paperId));
				answer2.setQuestionId(Integer.parseInt(questionId));
				baseService.editAnswer(answer2);
			}
			r.put("result", "success");
			r.put("msg", "保存成功");
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "保存失败");
		}
		
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@RequestMapping("lanmuForwardOrBackward")
	@ResponseBody
	public void lanmuForwardOrBackward(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String id = request.getParameter("id");
		String type = request.getParameter("type");
		HashMap<String, String>r=new HashMap<String, String>();
		HashMap<String, Object> queryParams = new HashMap<String, Object>();
		queryParams.put("^,sort", "asc");
		Integer count = publicService.getCategoryCount(queryParams);
		List<Category> category = publicService.getCategory(queryParams, 1, count);
		for (int i = 0; i < category.size(); i++) {
			if(category.get(i).getId().equals(Integer.parseInt(id))){
				Integer now = category.get(i).getSort();
				if("0".equals(type)){//前移
					if(i==0){
						r.put("result", "fail");
						r.put("msg", "已是第一个");
					}else{
						try {
							if(now==category.get(i-1).getSort()){
								category.get(i).setSort(category.get(i-1).getSort()-1);
								baseService.editCategory(category.get(i));
								category.get(i-1).setSort(now);
								baseService.editCategory(category.get(i-1));
							}else{
								category.get(i).setSort(category.get(i-1).getSort());
								baseService.editCategory(category.get(i));
								category.get(i-1).setSort(now);
								baseService.editCategory(category.get(i-1));
							}
							r.put("result", "success");
							r.put("msg", "前移成功");
						} catch (Exception e) {
							r.put("result", "fail");
							r.put("msg", "前移失败");
						}
						
					}
				}else if("1".equals(type)){//后移
					if(i==category.size()-1){
						r.put("result", "fail");
						r.put("msg", "已是最后一个");
					}else{
						try {
							if(now == category.get(i+1).getSort()){
								
							}else{
								category.get(i).setSort(category.get(i+1).getSort());
								baseService.editCategory(category.get(i));
								category.get(i+1).setSort(now+1);
								baseService.editCategory(category.get(i+1));
							}
							
							r.put("result", "success");
							r.put("msg", "后移成功");
						} catch (Exception e) {
							r.put("result", "fail");
							r.put("msg", "后移失败");
						}
						
					}
				}
			}
		}
		
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	
	// 系统管理 -->用户管理 -->添加 and 更新用户
	@SysLog(title="新增-后台用户",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
		@RequestMapping("userSave")
		@ResponseBody
		public void userAdd(HttpServletRequest request, HttpServletResponse response)
				throws Exception {
			String id = request.getParameter("id");
			String description = request.getParameter("description");
			String email = request.getParameter("email");
			String gender = request.getParameter("gender");
			String nickName = request.getParameter("nickName");
			String password = request.getParameter("password");
			String realName = request.getParameter("realName");
			String signature = request.getParameter("signature");
			String telephone = request.getParameter("telephone").trim();
			String type = request.getParameter("type");
			String username = request.getParameter("username");
			String avatarImg = request.getParameter("avatarImg");
			
			HashMap<String, String>r=new HashMap<String, String>();
			try {
				
				HashMap<String, Object> queryParams1 = new HashMap<String, Object>();
				queryParams1.put("=,username", username);
				Integer count = publicService.getUserCount(queryParams1);
				if(count>0){
					r.put("result", "fail");
					r.put("msg", "用户名已存在");
				}else{
					User user = new User();
					
					user.setAvatarImg(avatarImg==null?"":avatarImg.replace(FILESERVER, "").replace(FILEPATH, "").replace("//", "/"));
					user.setCreateTime(DateUtils.getDateTime());
					user.setDescription(description);
					user.setEmail(email);
					user.setGender(Integer.parseInt(gender));
					user.setNickName(nickName);
					user.setPassword(MD5.convert(password));
					user.setRealName(realName);
					user.setSignature(signature);
					user.setStatus(1);
					user.setTelephone(telephone);
					user.setType(Integer.parseInt(type));
					user.setUsername(username);
					baseService.saveUser(user);
					
					
					
					Member member = new Member();
					member.setAvatarImg(avatarImg==null?"":avatarImg.replace(FILESERVER, "").replace(FILEPATH, "").replace("//", "/"));
					member.setCreateTime(DateUtils.getDateTime());
					member.setDescription(description);
					member.setEmail(email);
					member.setGender(Integer.parseInt(gender));
					member.setNickName(nickName);
					member.setPassword(MD5.convert(password));
					member.setRealName(realName);
					member.setSignature(signature);
					member.setStatus(1);
					member.setTelephone(telephone);
					member.setType(Integer.parseInt(type));
					member.setUsername(username);
					baseService.saveMember(member);
					
					
					
					HashMap<String, Object> queryParams = new HashMap<String, Object>();
					queryParams.put("=,username", username);
					queryParams.put("=,telephone", telephone);
					List<User> user2 = publicService.getUser(queryParams , 1, 1);
					if("0".equals(type)){//管理员
						UserRole userRole = new UserRole();
						userRole.setUserId(user2.get(0).getId());
						userRole.setRoleId(2);
						baseService.saveUserRole(userRole);
					}else if("1".equals(type)){//教师
						UserRole userRole = new UserRole();
						userRole.setUserId(user2.get(0).getId());
						userRole.setRoleId(3);
						baseService.saveUserRole(userRole);
					}
					r.put("result", "success");
					r.put("msg", "保存成功");
				}
				
			} catch (Exception e) {
				r.put("result", "fail");
				r.put("msg", "保存失败");
			}
			
			String result = formatToJson(r);
			super.pringWriterToPage(result.toString(), "application/json", response);
		}
		
		
		
		//=======
		//===审核====
		//=======
		//课程审核
		@SysLog(title="审核-课程",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
		@RequestMapping("courseAudit")
		@ResponseBody
		public void courseAudit(HttpServletRequest request,
				HttpServletResponse response) throws Exception {
			String ids = request.getParameter("ids");
			String status = request.getParameter("status");
			String auditType = request.getParameter("auditType");
			String content = request.getParameter("content");
			String type = request.getParameter("type");//0:提交人，1审核人
			User u = publicService.findUser((Integer) request.getSession().getAttribute("userid"));
			HashMap<String, String>r=new HashMap<String, String>();
			
			String names="";
			
			try{
				String[] splits = ids.split(";");
				for (String string : splits) {
					if(!"".equals(string)){
						Course course = publicService.findCourse(Integer.parseInt(string));
						
						boolean flag=true;
						if("1".equals(auditType)){//查询题目是否全部注销
							HashMap<String, Object> queryParams = new HashMap<String, Object>();
							queryParams.put("=,courseId", string);
							Integer questionCount = publicService.getOnlineCount(queryParams );
							List<Online> questions = publicService.getOnline(queryParams, 1, questionCount);
							for (Online question : questions) {
								if(!"1".equals(question.getAuditType())&& 2!=question.getStatus()){
									flag=false;
									break;
								}
							}
						}
						if(flag){
							if((course.getAuditType().equals("0")&&(course.getStatus()==0||course.getStatus()==1))
									&&("1".equals(auditType)||"2".equals(auditType)||"3".equals(auditType))){
								names+=course.getName()+";";
							}else{
								course.setStatus(Integer.parseInt(status));
								course.setAuditType(auditType);
								baseService.editCourse(course);
								if("1".equals(type)){//审核人
									auditAdd(auditType, u.getId(), u.getUsername(), content, course.getId(), status, null, null, "0");
								}else{
									auditAdd(auditType, null, null , content, course.getId(), status,u.getId(), u.getUsername(), "0");
								}
								course=null;
							}
						}else{
							names+=course.getName()+";";
						}
					}
				}
				//资源类型(0-课程 1-题目 2-网班,3-直播，4-微课，5-广告，6-题库)
				
				r.put("result", "success");
				r.put("msg", "保存成功");
				r.put("names", names);
			} catch (Exception e) {
				e.printStackTrace();
				r.put("result", "fail");
				r.put("msg", "保存失败");
			}
			
			String result = super.formatToJson(r);
			super.pringWriterToPage(result, "application/json", response);
		}
		//微客审核
		@SysLog(title="审核-微课",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
		@RequestMapping("onlineAudit")
		@ResponseBody
		public void onlineAudit(HttpServletRequest request,
				HttpServletResponse response) throws Exception {
			String ids = request.getParameter("ids");
			String status = request.getParameter("status");
			String auditType = request.getParameter("auditType");
			String content = request.getParameter("content");
			String type = request.getParameter("type");//0:提交人，1审核人
			User u = publicService.findUser((Integer) request.getSession().getAttribute("userid"));
			HashMap<String, String>r=new HashMap<String, String>();
			
			String names="";
			try{
				String[] splits = ids.split(";");
				for (String string : splits) {
					if(!"".equals(string)){
						
						Online online = publicService.findOnline(Integer.parseInt(string));
						if((online.getAuditType().equals("0")&&(online.getStatus()==0||online.getStatus()==1))
								&&("1".equals(auditType)||"2".equals(auditType)||"3".equals(auditType))){
							names+=online.getName()+";";
						}else{
							online.setStatus(Integer.parseInt(status));
							online.setAuditType(auditType);
							baseService.editOnline(online);
							if("1".equals(type)){//审核人
								auditAdd(auditType, u.getId(), u.getUsername(), content, online.getId(), status, null, null, "4");
							}else{
								auditAdd(auditType, null, null , content, online.getId(), status,u.getId(), u.getUsername(), "4");
							}
							online=null;
						}
						
						
						//资源类型(0-课程 1-题目 2-网班,3-直播，4-微课，5-广告，6-题库)
					}
				}
				r.put("result", "success");
				r.put("msg", "保存成功");
				r.put("names", names);
			} catch (Exception e) {
				e.printStackTrace();
				r.put("result", "fail");
				r.put("msg", "保存失败");
			}
			
			String result = super.formatToJson(r);
			super.pringWriterToPage(result, "application/json", response);
		}
		//广告审核
		@SysLog(title="审核-广告",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
		@RequestMapping("advertisementAudit")
		@ResponseBody
		public void advertisementAudit(HttpServletRequest request,
				HttpServletResponse response) throws Exception {
			String ids = request.getParameter("ids");
			String status = request.getParameter("status");
			String auditType = request.getParameter("auditType");
			String content = request.getParameter("content");
			String type = request.getParameter("type");//0:提交人，1审核人
			User u = publicService.findUser((Integer) request.getSession().getAttribute("userid"));
			HashMap<String, String>r=new HashMap<String, String>();
			
			String names="";
			try{
				String[] splits = ids.split(";");
				for (String string : splits) {
					if(!"".equals(string)){
						Advertisement advertisement = publicService.findAdvertisement(Integer.parseInt(string));
						if((advertisement.getAuditType().equals("0")&&(advertisement.getStatus()==0||advertisement.getStatus()==1))
								&&("1".equals(auditType)||"2".equals(auditType)||"3".equals(auditType))){
							names+=advertisement.getName()+";";
						}else{
							advertisement.setStatus(Integer.parseInt(status));
							advertisement.setAuditType(auditType);
							baseService.editAdvertisement(advertisement);
							if("1".equals(type)){//审核人
								auditAdd(auditType, u.getId(), u.getUsername(), content, advertisement.getId(), status, null, null, "5");
							}else{
								auditAdd(auditType, null, null , content, advertisement.getId(), status,u.getId(), u.getUsername(), "5");
							}
							advertisement=null;
						}
						//资源类型(0-课程 1-题目 2-网班,3-直播，4-微课，5-广告，6-题库)
					}
				}
				r.put("result", "success");
				r.put("msg", "保存成功");
				r.put("names", names);
			} catch (Exception e) {
				e.printStackTrace();
				r.put("result", "fail");
				r.put("msg", "保存失败");
			}
			
			String result = super.formatToJson(r);
			super.pringWriterToPage(result, "application/json", response);
		}
		//网班审核
		@SysLog(title="审核-网班",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
		@RequestMapping("classesOnlineAudit")
		@ResponseBody
		public void classesOnlineAudit(HttpServletRequest request,
				HttpServletResponse response) throws Exception {
			String ids = request.getParameter("ids");
			String status = request.getParameter("status");
			String auditType = request.getParameter("auditType");
			String content = request.getParameter("content");
			String type = request.getParameter("type");//0:提交人，1审核人
			User u = publicService.findUser((Integer) request.getSession().getAttribute("userid"));
			HashMap<String, String>r=new HashMap<String, String>();
			
			String names="";
			try{
				String[] splits = ids.split(";");
				for (String string : splits) {
					if(!"".equals(string)){
						ClassesOnline classesOnline = publicService.findClassesOnline(Integer.parseInt(string));
						
						
						
						boolean bz=true;
						if("1".equals(auditType)){
							HashMap<String, Object> queryParams=new HashMap<String, Object>();
							queryParams.put("=,classesOnlineId", classesOnline.getId());
							Integer liveCount = publicService.getLiveCount(queryParams);
							List<Live> lives = publicService.getLive(queryParams, 1, liveCount);
							boolean flag=true;
							queryParams=null;
							queryParams=new HashMap<String, Object>();
							queryParams.put("=,type", "2");
							queryParams.put("=,status", "0");
							for (Live live : lives) {
								queryParams.put("=,resourceId", live.getId());
								Integer orderCount = publicService.getOrderCount(queryParams);
								if(orderCount>0){
									flag=false;
									break;
								}
							}
							if(!flag){
								bz=false;
								/*r.put("result", "fail");
								r.put("msg", "该网班下直播又被购买，不能注销");*/
								names+=classesOnline.getName()+";";
							}
						}
						if(bz){
							boolean flag=true;
							if("1".equals(auditType)){//查询题目是否全部注销//查询直播是否全部注销
								HashMap<String, Object> queryParams = new HashMap<String, Object>();
								//queryParams.put("=,questionDatabaseId", string);
								queryParams.put("=,classesOnlineId", string);
								Integer questionCount = publicService.getLiveCount(queryParams );
								List<Live> questions = publicService.getLive(queryParams, 1, questionCount);
								for (Live question : questions) {
									if(!"1".equals(question.getAuditType())&& 2!=question.getStatus()){
										flag=false;
										break;
									}
								}
							}
							if(flag){
								if((classesOnline.getAuditType().equals("0")&&("0".equals(classesOnline.getStatus())||"1".equals(classesOnline.getStatus())))
										&&("1".equals(auditType)||"2".equals(auditType)||"3".equals(auditType))){
									names+=classesOnline.getName()+";";
								}else{
									classesOnline.setStatus(status);
									classesOnline.setAuditType(auditType);
									baseService.editClassesOnline(classesOnline);
									if("1".equals(type)){//审核人
										auditAdd(auditType, u.getId(), u.getUsername(), content, classesOnline.getId(), status, null, null, "2");
									}else{
										auditAdd(auditType, null, null , content, classesOnline.getId(), status,u.getId(), u.getUsername(), "2");
									}
									classesOnline=null;
								}
							}else{
								names+=classesOnline.getName()+";";
							}
						}
						//资源类型(0-课程 1-题目 2-网班,3-直播，4-微课，5-广告，6-题库)
					}
					r.put("result", "success");
					if(r.get("msg")==null){
						r.put("msg", "保存成功");
					}
					r.put("names", names);
				}
			} catch (Exception e) {
				e.printStackTrace();
				r.put("result", "fail");
				r.put("msg", "保存失败");
			}
			
			String result = super.formatToJson(r);
			super.pringWriterToPage(result, "application/json", response);
		}
		//直播审核
		@SysLog(title="审核-直播",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
		@RequestMapping("liveAudit")
		@ResponseBody
		public void liveAudit(HttpServletRequest request,
				HttpServletResponse response) throws Exception {
			String ids = request.getParameter("ids");
			String status = request.getParameter("status");
			String auditType = request.getParameter("auditType");
			String content = request.getParameter("content");
			String type = request.getParameter("type");//0:提交人，1审核人
			User u = publicService.findUser((Integer) request.getSession().getAttribute("userid"));
			HashMap<String, String>r=new HashMap<String, String>();
			
			String names="";
			try{
				String[] splits = ids.split(";");
				for (String string : splits) {
					if(!"".equals(string)){
						Live live = publicService.findLive(Integer.parseInt(string));
						if((live.getAuditType().equals("0")&&(live.getStatus()==0||live.getStatus()==1))
								&&("1".equals(auditType)||"2".equals(auditType)||"3".equals(auditType))){
							names+=live.getName()+";";
						}else{
							live.setStatus(Integer.parseInt(status));
							live.setAuditType(auditType);
							baseService.editLive(live);
							if("1".equals(type)){//审核人
								auditAdd(auditType, u.getId(), u.getUsername(), content, live.getId(), status, null, null, "3");
							}else{
								auditAdd(auditType, null, null , content, live.getId(), status,u.getId(), u.getUsername(), "3");
							}
							live=null;
						}
						//资源类型(0-课程 1-题目 2-网班,3-直播，4-微课，5-广告，6-题库)
					}
				}
				r.put("result", "success");
				r.put("msg", "保存成功");
				r.put("names", names);
			} catch (Exception e) {
				e.printStackTrace();
				r.put("result", "fail");
				r.put("msg", "保存失败");
			}
			
			String result = super.formatToJson(r);
			super.pringWriterToPage(result, "application/json", response);
		}
		//题目审核
		@SysLog(title="审核-题目",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
		@RequestMapping("questionAudit")
		@ResponseBody
		public void questionAudit(HttpServletRequest request,
				HttpServletResponse response) throws Exception {
			String ids = request.getParameter("ids");
			String status = request.getParameter("status");
			String auditType = request.getParameter("auditType");
			String content = request.getParameter("content");
			String type = request.getParameter("type");//0:提交人，1审核人
			User u = publicService.findUser((Integer) request.getSession().getAttribute("userid"));
			HashMap<String, String>r=new HashMap<String, String>();
			
			String names="";
			try{
				String[] splits = ids.split(";");
				for (String string : splits) {
					if(!"".equals(string)){
						Question question = publicService.findQuestion(Integer.parseInt(string));
						if((question.getAuditType().equals("0")&&(question.getStatus()==0||question.getStatus()==1))
								&&("1".equals(auditType)||"2".equals(auditType)||"3".equals(auditType))){
							names+=question.getName()+";";
						}else{
							question.setStatus(Integer.parseInt(status));
							question.setAuditType(auditType);
							baseService.editQuestion(question);
							if("1".equals(type)){//审核人
								auditAdd(auditType, u.getId(), u.getUsername(), content, question.getId(), status, null, null, "1");
							}else{
								auditAdd(auditType, null, null , content, question.getId(), status,u.getId(), u.getUsername(), "1");
							}
							question=null;
						}
						
						//资源类型(0-课程 1-题目 2-网班,3-直播，4-微课，5-广告，6-题库)
					}
				}
				r.put("result", "success");
				r.put("msg", "保存成功");
				r.put("names", names);
			} catch (Exception e) {
				e.printStackTrace();
				r.put("result", "fail");
				r.put("msg", "保存失败");
			}
			
			String result = super.formatToJson(r);
			super.pringWriterToPage(result, "application/json", response);
		}
		//题库审核
		@SysLog(title="审核-题库",businessType=BusinessType.INSERT,operatorType=OperatorType.MANAGE)
		@RequestMapping("questionDatabaseAudit")
		@ResponseBody
		public void questionDatabaseAudit(HttpServletRequest request,
				HttpServletResponse response) throws Exception {
			String ids = request.getParameter("ids");
			String status = request.getParameter("status");
			String auditType = request.getParameter("auditType");
			String content = request.getParameter("content");
			String type = request.getParameter("type");//0:提交人，1审核人
			User u = publicService.findUser((Integer) request.getSession().getAttribute("userid"));
			HashMap<String, String>r=new HashMap<String, String>();
			
			String names="";
			String questionNames="";
			try{
				String[] splits = ids.split(";");
				for (String string : splits) {
					if(!"".equals(string)){
						QuestionDatabase questionDatabase = publicService.findQuestionDatabase(Integer.parseInt(string));
						boolean flag=true;
						if("1".equals(auditType)){//查询题目是否全部注销
							HashMap<String, Object> queryParams = new HashMap<String, Object>();
							queryParams.put("=,questionDatabaseId", string);
							Integer questionCount = publicService.getQuestionCount(queryParams );
							List<Question> questions = publicService.getQuestion(queryParams, 1, questionCount);
							for (Question question : questions) {
								if(!"1".equals(question.getAuditType())&& 2!=question.getStatus()){
									flag=false;
									break;
								}
							}
						}
						if("1".equals(auditType)){
							boolean tiKuZhuXiao = tiKuZhuXiao(string);
							if(!tiKuZhuXiao){
								flag=false;
							}
						}
						if(flag){
							if((questionDatabase.getAuditType().equals("0")&&(questionDatabase.getStatus()==0||questionDatabase.getStatus()==1))
									&&("1".equals(auditType)||"2".equals(auditType)||"3".equals(auditType))){
								names+=questionDatabase.getName()+";";
							}else{
								questionDatabase.setStatus(Integer.parseInt(status));
								questionDatabase.setAuditType(auditType);
								baseService.editQuestionDatabase(questionDatabase);
								if("1".equals(type)){//审核人
									auditAdd(auditType, u.getId(), u.getUsername(), content, questionDatabase.getId(), status, null, null, "6");
								}else{
									auditAdd(auditType, null, null , content, questionDatabase.getId(), status,u.getId(), u.getUsername(), "6");
								}
								questionDatabase=null;
							}
						}else{
							names+=questionDatabase.getName()+";";
						}
						
						//资源类型(0-课程 1-题目 2-网班,3-直播，4-微课，5-广告，6-题库)
					}
				}
				r.put("result", "success");
				r.put("msg", "保存成功");
				r.put("names", names);
			} catch (Exception e) {
				e.printStackTrace();
				r.put("result", "fail");
				r.put("msg", "保存失败");
			}
			
			String result = super.formatToJson(r);
			super.pringWriterToPage(result, "application/json", response);
		}
		public boolean tiKuZhuXiao(String id){
			HashMap<String, Object> queryParams = new HashMap<String, Object>();
			queryParams.put("=,questionDatabaseId", id);
			Integer questionCount = publicService.getQuestionCount(queryParams);
			List<Question> questions = publicService.getQuestion(queryParams, 1, questionCount);
			for (Question question : questions) {
				queryParams = null;
				queryParams = new HashMap<String, Object>();
				queryParams.put("=,questionId", question.getId());
				Set<Integer>s=new HashSet<Integer>();
				Integer courseQuestionCount = publicService.getCourseQuestionCount(queryParams);
				List<CourseQuestion> courseQuestions = publicService.getCourseQuestion(queryParams, 1, courseQuestionCount);
				for (CourseQuestion courseQuestion : courseQuestions) {
					s.add(courseQuestion.getCourseId());
				}
				for (Integer i : s) {
					queryParams = null;
					queryParams = new HashMap<String, Object>();
					queryParams.put("=,resourceId", i);
					queryParams.put("=,type", "0");
					Integer orderCount = publicService.getOrderCount(queryParams);
					if(orderCount>0){
						return false;
					}
				}
				s=new HashSet<Integer>();
				Integer liveQuestionCount = publicService.getLiveQuestionCount(queryParams);
				List<LiveQuestion> liveQuestions = publicService.getLiveQuestion(queryParams, 1, liveQuestionCount);
				for (LiveQuestion liveQuestion : liveQuestions) {
					s.add(liveQuestion.getLiveId());
				}
				for (Integer i : s) {
					queryParams = null;
					queryParams = new HashMap<String, Object>();
					queryParams.put("=,resourceId", i);
					queryParams.put("=,type", "2");
					Integer orderCount = publicService.getOrderCount(queryParams);
					if(orderCount>0){
						return false;
					}
				}
				s=new HashSet<Integer>();
				Integer onlineQuestionCount = publicService.getOnlineQuestionCount(queryParams);
				List<OnlineQuestion> lineQuestions = publicService.getOnlineQuestion(queryParams, 1, onlineQuestionCount);
				for (OnlineQuestion onlineQuestion : lineQuestions) {
					s.add(onlineQuestion.getOnlineId());
				}
				for (Integer i : s) {
					queryParams = null;
					queryParams = new HashMap<String, Object>();
					queryParams.put("=,resourceId", i);
					queryParams.put("=,type", "1");
					Integer orderCount = publicService.getOrderCount(queryParams);
					if(orderCount>0){
						return false;
					}
				}
			}
			
			return true;
		}
		/**
		 * 
		 * @param auditType
		 * @param auditUserId
		 * @param auditUserName
		 * @param content
		 * @param resourceId
		 * @param status
		 * @param submitUserId
		 * @param submitUsreName
		 * @param type 0-课程 1-题目 2-网班,3-直播，4-微课，5-广告
		 */
		public void auditAdd(String auditType,Integer auditUserId,String auditUserName,
				String content,Integer resourceId,String status,Integer submitUserId,
				String submitUsreName,String type){
			Audit audit = new Audit();
			
			audit.setAuditType(auditType);
			if(auditUserId!=null &&!"".equals(auditUserId)){
				audit.setAuditUserId(auditUserId);
			}
			
			audit.setAuditUserName(auditUserName);
			audit.setContent(content);
			audit.setCreateTime(DateUtils.getDateTime());
			audit.setResourceId(resourceId);
			audit.setStatus(Integer.parseInt(status));
			if(submitUserId!=null &&!"".equals(submitUserId)){
				audit.setSubmitUserId(submitUserId);
			}
			audit.setSubmitUsreName(submitUsreName);
			audit.setType(type);
			baseService.saveAudit(audit);
		}
}
